package com.qjl.shopping.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author:Lijun
 * @Date:2022/6/15
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //拦截器
    /*设置跨域请求的处理*/
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowCredentials(false)//禁用cooke
                .allowedHeaders("*")
                .allowedMethods("GET","POST","DELETE","PUT","OPTIONS")
                .maxAge(36000);//OPTION与请求
    }
}
